package design.pattern.prototype.deep;

import java.time.LocalDateTime;

/**
 * @description:
 * @author: liuzhangcheng
 **/
public class ShallowPrototypeTest {
    public static void main(String[] args) {
        QiTianDaSheng prototype = new QiTianDaSheng();
        prototype.setWeight(140);
        prototype.setHeight(180);
        prototype.setDate(LocalDateTime.now());
        prototype.setJinGuBang(new JinGuBang(234, 111));


        QiTianDaSheng prototypeClone = (QiTianDaSheng) prototype.shallowClone();
        System.out.println("浅克隆：");
        System.out.println("原型对象：" + prototype);
        System.out.println("克隆对象：" + prototypeClone);
        System.out.println("原型对象引用JiGuBang对象地址：" + prototype.getJinGuBang());
        System.out.println("克隆对象引用JiGuBang对象地址：" + prototypeClone.getJinGuBang());
        // 结果为false
        System.out.println("原型与克隆对象引用List对象地址比较：" + (prototype.getJinGuBang() == prototypeClone.getJinGuBang()));


    }
}
